package com.cgx.tablet.beeper.presenter;

import com.cgx.tablet.beeper.api.ApiCallback;
import com.cgx.tablet.beeper.api.ApiUtil;
import com.cgx.tablet.beeper.base.BasePresenter;
import com.cgx.tablet.beeper.bean.BizTransBean;
import com.cgx.tablet.beeper.bean.response.ListResponse;
import com.cgx.tablet.beeper.bean.response.MsgResponse;
import com.cgx.tablet.beeper.view.IBizTransView;

/**
 * Created by Administrator on 2018/9/14 0014.
 */

public class BizTransPresenter extends BasePresenter{

    private IBizTransView view;
    public BizTransPresenter(IBizTransView view) {
        super(view);
        this.view = view;
    }

    public void getBizs(String bizId) {
        callApi(ApiUtil.apiService.getBizs(bizId), new ApiCallback<ListResponse<BizTransBean>>() {
            @Override
            public void onSuccess(final ListResponse<BizTransBean> response) {
                view.getBizsSuccess(response.getData());
            }

            @Override
            public void onFail(String code, String msg) {
                view.getBizsFail(code, msg);
            }
        }, false);
    }

    public void bizTrans(String tid, String bizId, boolean priority) {
        callApi(ApiUtil.apiService.bizTrans(tid, bizId, priority), new ApiCallback<MsgResponse>() {
            @Override
            public void onSuccess(final MsgResponse response) {
                view.bizTransSuccess();
            }

            @Override
            public void onFail(String code, String msg) {
                view.bizTransFail(code, msg);
            }
        });
    }
}
